<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
    <%--常量--%>
    <%@ include file="/common/constHead.jsp"%>
    <%--jQuery--%>
    <%@ include file="/common/jqueryHead.jsp"%>
    <%--jo--%>
    <%@ include file="/common/joHead.jsp"%>
    <%--bootstrap和字体--%>
    <%@ include file="/common/bootstrapHead.jsp"%>
    <%--layer--%>
    <%@ include file="/common/layerHead.jsp"%>
    <%--公共--%>
    <%@ include file="/common/commonHead.jsp"%>
    <%--日期选择--%>
    <%@ include file="/common/dateHead.jsp"%>
    <%@ include file="/common/uploadHead.jsp"%>
    <title>项目表单</title>
        <script type="text/javascript">
            $(function(){
                var jParams = {
                    "PKName" : "id",//主键属性名
                    "saveAfter" : "toEdit",
                    "addUrl" : "business/project/insert.action",//新增
                    "deleteUrl" : "",//删除
                    "updateUrl" : "",//修改
                    "formDataUrl" : ""	//查询
                };
                joForm.initFormPage(jParams);//初始化
            });
            //初始化表单值前处理
            joForm.initFormValueBefore = function(oJson){
                oJson.endTime = jo.formatDate(oJson.endTime);
                oJson.finishTime = jo.formatDate(oJson.finishTime);
                oJson.createTime = jo.formatDate(oJson.createTime);
                oJson.updateTime = jo.formatDate(oJson.updateTime);
            };
            joForm.dealDataAtSaveBefore = function(oData){
                oData.attachment = '';
                if(fileMap){
                    for(var k in fileMap){
                        oData.attachment += ',' + k;
                    }
                }
                if(oData.attachment){
                    oData.attachment = oData.attachment.substring(1);
                }
            };
            //上传照片
            var fileMap = {};
            function upload(){
                jo.uploadFile("{URL_FS}fs/file/upload", function(success, file, json){
                    if(success && json){
                        jo.closeUploadDialog();//关闭上传窗口
                        if(json.code == "0" && json.data[0]){
                            var item = json.data[0];
                            fileMap[item.id] = json.data[0];//记录文件
                            $("#attachment").val(item.id);
                            $("#attachmentList").append('<div><a class="cursor-hand" style="display: inline;">'+item.name+'</a>&nbsp;&nbsp;<span class="cursor-hand fa fa-close" onclick="dropFile(\''+item.id+'\', this)" title="删除"></span></div>');
                            jo.showMsg("上传成功,点击提交按钮进行保存!", {icon:1});
                        }else{
                            jo.showMsg(json.info);
                        }
                    }
                });
            }
            function dropFile(fileId, obj){
                if(jo.isValid(fileId)){
                    jo.confirm("您确定要删除该文件吗?", {title:"删除确认"}, function(){
                        jo.postAjax("{URL_FS}fs/file/dropFile.action", {"fileId" : fileId}, function(json){
                            if(json && json.code == "0"){
                                jo.showMsg("成功删除文件!");
                                $(obj).parent().remove();
                                delete(fileMap[fileId]);
                            }if(json && json.code == "-1"){
                                jo.showMsg(json.info);
                            }
                        });
                    });
                }else{
                    console.error("文件编号无效,无法删除!");
                }
            }
        </script>
</head>
<body class="">
<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12 col-lg-12 col-md-12 col-sm-12">
            <h3>项目信息登记</h3>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12 col-lg-12 col-md-12 col-sm-12">
            <form id="pageForm" name="pageForm" class="form-horizontal" action="" method="post">
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">项目名称</label>
                    <div class="col-sm-10">
                        <input type="text"  name="name" class="form-control input-sm" ErrEmpty="请输入项目名称"  placeholder="请输入项目名称"/>
                        <input type="hidden"  name="id" class="form-control input-sm readonly-edit" />
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">说　　明</label>
                    <div class="col-sm-10">
                        <textarea  name="remark" class="form-control input-sm" ></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">价　　格</label>
                    <div class="col-sm-10">
                        <input type="text"  name="price" class="form-control input-sm" />
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">截止时间</label>
                    <div class="col-sm-10">
                        <input type="text" onclick="laydate()" name="endTime" class="form-control input-sm" />
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">相关文档</label>
                    <div class="col-sm-10">
                        <button type="button" isShow="joForm.isAdd" class="btn btn-sm btn-outline btn-info" onclick="upload()">
                            <i class="fa fa-upload" aria-hidden="true"></i>&nbsp;上传文档
                        </button>
                        <%--<input type="text" id="attachment"  name="attachment" class="form-control input-sm" />--%>
                        <div id="attachmentList" style="line-height: 1.6;font-size: 14px;">
                            <%--<div><a class="cursor-hand" style="display: inline;">xxx</a>&nbsp;&nbsp;<span class="cursor-hand" onclick="dropFile()"><i class="fa fa-close" aria-hidden="true"></i></span></div>--%>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="button" isShow="joForm.isAdd" class="btn btn-sm btn-outline btn-primary" onclick="joForm.save()">
                            <i class="fa fa-check" aria-hidden="true"></i>&nbsp;&nbsp;提交
                        </button>
                    </div>

                </div>

                <%--<table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
                    <tr>

                        <td width="15%" width="15%" class="active" align="">项目名称</td>
                        <td width="85%" class="tnt">
                            <input type="text"  name="name" class="form-control input-sm" />
                            <input type="hidden"  name="id" class="form-control input-sm readonly-edit" />
                        </td>
                    </tr>
                    <tr>
                       
                        <td width="15%" class="active" align="">说　　明</td>
                        <td class="tnt">
                            <textarea  name="remark" class="form-control input-sm" ></textarea>
                        </td>
                    </tr>
                    <tr>

                        <td width="15%" class="active" align="">价　　格</td>
                        <td class="tnt">
                            <input type="text"  name="price" class="form-control input-sm" />
                        </td>
                    </tr>
                    <tr>
                        <td width="15%" class="active" align="">截止时间</td>
                        <td class="tnt">
                            <input type="text" onclick="laydate()" name="endTime" class="form-control input-sm" />
                        </td>
                    </tr>

                    <tr>
                        <td width="15%" class="active" align="">完成时间</td>
                        <td class="tnt">
                            <input type="text" onclick="laydate()" name="finishTime" class="form-control input-sm" />
                        </td>
                    </tr>
                    <tr>

                        <td width="15%" class="active" align="">登记时间</td>
                        <td class="tnt">
                            <input type="text" readonly name="createTime" class="form-control input-sm" />
                        </td>
                    </tr>
                </table>--%>
            </form>
        </div>
    </div>
</div>



<script src="<%=URL_STATIC%>static/plugin/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script type="text/javascript">
    jo.formatUI();//格式化jo组件
</script>
</body>
</html>
